/*
 Copyright (C) 2015 Apple Inc. All Rights Reserved.
 See LICENSE.txt for this sample’s licensing information
 
 Abstract:
 The application-specific delegate class.
*/

#import "AAPLAppDelegate.h"
#import "LTCTestViewController.h"
@interface AAPLAppDelegate() <UISplitViewControllerDelegate>
@end

@implementation AAPLAppDelegate

#pragma mark - UIApplicationDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//    UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
//    
//    splitViewController.delegate = self;
//    splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;
    
    LTCTestViewController* vc=[[LTCTestViewController alloc]init];
    vc.view.backgroundColor=[UIColor whiteColor];
    self.window.rootViewController=vc;
    [self.window makeKeyAndVisible];
    
    //
    int  i=12;
    int sum=0;
    for (int a =2; a<=i; a++) {
        sum = sum+(a-1);
        NSLog(@"%02d\n",sum);
        int value = (arc4random() % i) + 1;
        NSLog(@"随机数 ：  %02d",value);
        
    }
    
    //红区
    NSArray *temp = [NSArray arrayWithObjects:@"01", @"02", @"03", @"04", @"05", @"06",@"07", @"8",@"9",@"10", @"11",@"12",@"13", @"14", @"15", @"16", @"17", @"18",@"19", @"20",@"21",@"22", @"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35",nil];
    NSMutableArray *tempArray = [[NSMutableArray alloc] initWithArray:temp];
    NSMutableArray *resultArray = [[NSMutableArray alloc] init];
    int count = 33;//(要取的球个数)
    int totalCount = (int)temp.count;//(小球的总个数)
    NSLog(@"count:%d",count);
    for (i = 0; i < count; i ++) {
        int index = arc4random() % (totalCount-i);
        [resultArray addObject:[tempArray objectAtIndex:index]];
        [tempArray removeObjectAtIndex:index];
        
    }
    NSLog(@"%@",resultArray);
    NSMutableSet *resultSet = [[NSMutableSet alloc] init];
    for (i = 0; i < 5; i ++) {
        
        int index = arc4random() % 12 +1;
        NSNumber* num=[[NSNumber alloc]initWithInt:index];
        [resultSet addObject:num];
        if (i == 4 && resultSet.count<5) {
            i--;
        }
    }
    
    NSLog(@"打印 set : %@",resultSet);
    
    return YES;
}
-(NSArray *)randomArray
{
    //随机数从这里边产生
    NSMutableArray *startArray=[[NSMutableArray alloc] initWithObjects:@0,@1,@2,@3,@4,@5,@6,@7, nil];
    //随机数产生结果
    NSMutableArray *resultArray=[[NSMutableArray alloc] initWithCapacity:0];
    //随机数个数
    NSInteger m=8;
    for (int i=0; i<m; i++) {
        int t=arc4random()%startArray.count;
        resultArray[i]=startArray[t];
        startArray[t]=[startArray lastObject]; //为更好的乱序，故交换下位置
        [startArray removeLastObject];
    }
    return resultArray;
}
#pragma mark - UISplitViewControllerDelegate

- (UISplitViewControllerDisplayMode)targetDisplayModeForActionInSplitViewController:(UISplitViewController *)splitViewController {
    return UISplitViewControllerDisplayModeAllVisible;
}

@end
